package com.doradance.account.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Region;
import android.util.AttributeSet;
import android.widget.ImageView;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;

/**
 * Created by Administrator on 2018/2/27.
 */

/**
 * 切除圆角
     */ @SuppressLint("AppCompatCustomView")
public class GlideRoundTransform extends ImageView {
         private float radiusX; private float radiusY;
         public GlideRoundTransform(Context context) { super(context); init(); }
         public GlideRoundTransform(Context context, AttributeSet attrs) { super(context, attrs); init(); }
         public GlideRoundTransform(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } /**
 *
 * @param rx x方向弧度
 * @param ry y方向弧度
 */ public void setRadius(float rx, float ry) {
     this.radiusX = rx;
     this.radiusY = ry;
 } private void init() {
     radiusX = 58; radiusY = 58;
 } @Override protected void onDraw(Canvas canvas) {
     Path path = new Path();
     Rect rect = new Rect(0, 0, getWidth(), getHeight());
     RectF rectF = new RectF(rect);
     path.addRoundRect(rectF, radiusX, radiusY, Path.Direction.CCW);
     canvas.clipPath(path, Region.Op.REPLACE);
     //Op.REPLACE这个范围内的都将显示，超出的部分覆盖 super.onDraw(canvas);
        } }